// Myriad3D.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include "Myriad3D.h"


Kernel* g_kernel = NULL;

/**
    Setup the game 
 */
void SetupGame( Kernel* kernel ) 
{
    GameManager* game        = kernel->GetGame();
    Console* console         = kernel->GetConsole();
    RenderManager* render    = kernel->GetRenderer();
    
    InGameState* inGame = new InGameState;
    inGame->Init();

    game->AddState( inGame );                                         // register the state with the game manager
    render->AddStateView( new InGameStateView( inGame ) );            // now register that states visual rep to the render manager

    game->AddState( console );                                        // add the console state
    render->AddStateView( new ConsoleView( console ) );

    // TEMP
    game->PushState( inGame->GetName() );                             // Activate the in game state  

    // TEMP
    kernel->GetVFileSystem()->AddZipFile( "pak0.pk3" );

}

// Engine entry point
int _tmain(int argc, _TCHAR* argv[])
{
    g_kernel = new Kernel();
    /**
     * Init all engine subsystems
     */
    if ( !g_kernel->Init( "config.cfg" ) )
    {
        SetupGame( g_kernel );
        // Run processes
        g_kernel->Execute();
    }
    // savely shutdown
    g_kernel->Shutdown();

    // delete the engine
    if ( g_kernel )
        delete g_kernel;

    return 0;

}
